
import java.util.ArrayList;

public class Issue
{
    public Issue()
    {
    }

    public double value;
    public String comment;
    public Task task = null;
    public ArrayList<Team> teams = new ArrayList<Team>();

    public String getLabel()
    {
        String brief;
        if (comment.length() > 128) brief = comment.substring(0,128);
        else brief = comment;

        if (task == null) return "[] " + brief;
        else return "[" + task.name + "] " + brief;
    }

    public void freeTeams()
    {
        for (int i = 0; i < teams.size(); i++)
        {
            Team t = teams.get(i);
            t.issues.remove(this);
        }
        teams.clear();
    }

    public void addTeam(Team t)
    {
        if (teams.contains(t)) return;
        teams.add(t);
        if (t.issues.contains(this)) return;
        t.issues.add(this);
    }

    public void removeTeam(Team t)
    {
        if (!teams.contains(t)) return;

        teams.remove(t);
        t.issues.remove(this);        
    }
}
